package com.design.movieticket.login.service;

import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.mail.Transport;

@Service
public class SendEmailService {
    @Resource
    JavaMailSenderImpl mailSender;

    public void sendEmail(String number){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("111222333xxx@qq.com");//配置邮箱地址
        message.setTo("111222333xxx@qq.com");//配置邮箱地址
        message.setSubject("注册验证码");
        message.setText("您正在使用睇影麦票系统，验证码为" + number + ',' + "请注意勿将验证码泄露给他人");
        try {
            mailSender.send(message);
        }catch (MailException e){
            e.printStackTrace();
        }

    }
}
